from collections import defaultdict

class Hex:
  def __init__(self, number = -1, type = None, id = 0):
    self.number = number
    self.type = type
    self.id = id
    
  def __repr__(self):
    return "id:%d,%d=>%s" % (self.id, self.number, self.type)


hex_to_vertex_map = {
                     0:[0,3,4,7,8,12],
                     1:[1,4,5,8,9,13], 
                     2:[2,5,6,9,10,14], 
                     3:[7,11,12,16,17,22], 
                     4:[8,12,13,17,18,23], 
                     5:[9,13,14,18,19,24], 
                     6:[10,14,15,19,20,25], 
                     7:[16,21,22,27,28,33], 
                     8:[17,22,23,28,29,34], 
                     9:[18,23,24,29,30,35], 
                     10:[19,24,25,30,31,36], 
                     11:[20,25,26,31,32,37], 
                     12:[28,33,34,38,39,43], 
                     13:[29,34,35,39,40,44], 
                     14:[30,35,36,40,41,45], 
                     15:[31,36,37,41,42,46], 
                     16:[39,43,44,47,48,51], 
                     17:[40,44,45,48,49,52],
                     18:[41,45,46,49,50,53]  
                    }

vertex_to_hex_map = defaultdict(list)
for hex, vertices in hex_to_vertex_map.items():
  for vertex in vertices: 
    vertex_to_hex_map[vertex].append(hex)

vertex_to_edge_map = {
                      0:[0,1],
                      1:[2,3],
                      2:[4,5],
                      3:[0,6],
                      4:[1,2,7],
                      5:[3,4,8],
                      6:[5,9],
                      7:[6,10,11],
                      8:[7,12,13],
                      9:[8,14,15],
                      10:[9,16,17],
                      11:[10,18],
                      12:[11,12,19],
                      13:[13,14,20],
                      14:[15,16,21],
                      15:[17,22],
                      16:[18,23,24],
                      17:[19,25,26],
                      18:[20,27,28],
                      19:[21,29,30],
                      20:[22,31,32],
                      21:[23,33],
                      22:[24,25,34],
                      23:[26,27,35],
                      24:[28,29,36],
                      25:[30,31,37],
                      26:[32,38],
                      27:[33,39],
                      28:[34,40,41],
                      29:[35,42,43],
                      30:[36,44,45],
                      31:[37,46,47],
                      32:[38,48],
                      33:[39,40,49],
                      34:[41,42,50],
                      35:[43,44,51],
                      36:[45,46,52],
                      37:[47,48,53],
                      38:[49,54],
                      39:[50,55,56],
                      40:[51,57,58],
                      41:[52,59,60],
                      42:[53,61],
                      43:[54,55,62],
                      44:[56,57,63],
                      45:[58,59,64],
                      46:[60,61,65],
                      47:[62,66],
                      48:[63,67,68],
                      49:[64,69,70],
                      50:[65,71],
                      51:[66,67],
                      52:[68,69],
                      53:[70,71]
                      }

edge_to_vertex_map = defaultdict(list)
for vertex, edges in vertex_to_edge_map.items():
  for edge in edges: 
    edge_to_vertex_map[edge].append(vertex)
    
vertex_to_vertex_map = defaultdict(list)
for vertex, edges in vertex_to_edge_map.items():
  for edge in edges: 
    vertex_to_vertex_map[vertex].extend(edge_to_vertex_map[edge])
    vertex_to_vertex_map[vertex] = sorted(list(set(vertex_to_vertex_map[vertex])))
# vertexes should not have themselves
for key_vertex, vertices in vertex_to_vertex_map.items():
  vertices.remove(key_vertex)
  
edge_to_edge_map = defaultdict(list)
for edge, vertices in edge_to_vertex_map.items():
  for vertex in vertices: 
    edge_to_edge_map[edge].extend(vertex_to_edge_map[vertex])
    edge_to_edge_map[edge] = sorted(list(set(edge_to_edge_map[edge])))
# vertexes should not have themselves
for key_edge, edges in edge_to_edge_map.items():
  edges.remove(key_edge)

